package com.yunwaikeji.gy_tool_library_test

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.View
import com.google.gson.JsonObject
import com.yunwaikeji.gy_tool_library.mvvm.view.fragment.GYRefreshFragment
import kotlinx.android.synthetic.main.gy_activity.*

class MainFragment : GYRefreshFragment<BaseModel, LoginViewModel>() {
    override fun getLayoutId(): Int = R.layout.gy_activity

    override fun initView(context: Context, view: View, savedInstanceState: Bundle?) {
        showTopBar(false)
        mViewAdmin.topBar.setTitleText("测试哈哈哈哈")
        mViewAdmin.setSmartRefresh(true, true)
        clickTv.setOnClickListener { v: View? ->
            val jsonObject = JsonObject()
            jsonObject.addProperty("userPhone", "19136198797")
            jsonObject.addProperty("password", "123456")
            mViewModel.login(jsonObject)
        }
        mViewModel.loginData.observeForever { o ->
            Log.e(
                "=======",
                "1=======" + mViewAdmin.gson.toJson(o)
            )
        }
    }

    override fun initViewDelayed(context: Context, view: View, savedInstanceState: Bundle?) {
    }

    override fun initData(refresh: Boolean) {
    }

    override fun initDataObserver(context: Context) {
    }
}